﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public class MyArrangement
    {
        public const int MAX_NUM = 10;
        public static int[] Nums = new int[MAX_NUM];
        public static int length;

        public static void CountArrangement(int[] num, int pos)
        {
            PrintfNum(num);

            for (int i = length - 2; i > pos - 1; i--)
                NextArrangement(num, i);
        }

        static void NextArrangement(int[] num, int pos)
        {
            int[] cop = new int[length];

            for (int i = pos + 1; i < length; i++)
            {
                if (num[i] > num[pos])
                {
                    for (int t = 0; t < length; t++)
                        cop[t] = num[t];
                    for (int j = i; j > pos; j--)
                    {
                        int temp = cop[j];
                        cop[j] = cop[j - 1];
                        cop[j - 1] = temp;
                    }
                    CountArrangement(cop, pos + 1);
                }
            }
        }

        static void PrintfNum(int[] num)
        {
            for (int i = 0; i < length; i++)
                Console.Write(num[i]);
            Console.WriteLine();
        }
    }
}
